<!DOCTYPE html>
<html>
<head>
    <title></title>
    <link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css">
    <script type="text/javascript" src="/static/layui/layui.js"></script>
</head>
<body style="padding:10px;">
<form class="layui-form">
    <input type="hidden" name="id" value="{$shop.id}">
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="title" value="{$shop.title}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">分类</label>
        <div class="layui-input-inline">
            <select name="cat">
                <option value=0 {if $shop.cat==0} selected {/if}></option>
                {volist name="cat" id="cat_v"}
                <option value="{$cat_v.id}" {if $shop.cat==$cat_v.id} selected {/if}>{$cat_v.name}</option>
                {/volist}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">原价</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="price" value="{$shop.price}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">折扣</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="discount" value="{$shop.discount}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">库存</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="stock" value="{$shop.stock}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-inline">
            <select name="status">
                <option value="1" {if $shop.status==1} selected {/if}>开启</option>
                <option value="0" {if $shop.status==0} selected {/if}>关闭</option>
            </select>
        </div>
    </div>
</form>
<div class="layui-form-item">
    <div class="layui-input-block">
        <button class="layui-btn" onclick="save()">保存</button>
    </div>
</div>
<script type="text/javascript">
    layui.use(['layer','form'],function(){
        form = layui.form;
        layer = layui.layer;
        $ = layui.jquery;
    });
    function save(){
        $.post('/index.php/Index/edit',$('form').serialize(),function(res){
            if(res.status==0){
                layer.alert(res.message,{icon:2});
            }else{
                layer.msg(res.message);
                setTimeout(function(){parent.window.location.reload();},1000);
            }
        },'json');
    }
</script>
</body>
</html>